package cn.edu.neusoft.wuguangsheng.flowerimpression.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.UserOrderGoodsBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.service.Service;

public class UserOrderInfoAdapter extends BaseAdapter<UserOrderGoodsBean> {

    public UserOrderInfoAdapter(Context context, List<UserOrderGoodsBean> items, int layoutResourse) {
        super(context, items, layoutResourse);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(context).inflate(layoutResourse,parent,false);
        UserOrderGoodsViewHolder viewHolder = new UserOrderGoodsViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final UserOrderGoodsViewHolder viewHolder=(UserOrderGoodsViewHolder) holder;
        final UserOrderGoodsBean userOrderGoodsBean=items.get(position);

        final String name = userOrderGoodsBean.getGood_name();
        final String price = userOrderGoodsBean.getGood_price();
        final String num = userOrderGoodsBean.getOg_goodnum();
        final String img = Service.BASE_URL+"flower_impression/public/uploads/"+userOrderGoodsBean.getGood_photo();
        Picasso.with(context).load(img).into(viewHolder.userordergoods_img);

        viewHolder.userordergoods_num.setText("X"+num);
        viewHolder.userordergoods_price.setText("￥"+price);
        viewHolder.userordergoods_name.setText(name);

    }
}
